package com.swt.gap.common;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * 请填写说明
 *
 * @author sx
 * @date 2020/5/13 16:32
 */
@Getter
@NoArgsConstructor
@AllArgsConstructor
public enum NodeTypeEnum {
    /**
     *结点类型
     */
    ENTITY(1, "实体"),
    EVENT(2, "事件"),
    DOC(3, "文档"),
    EXTERNAL(4, "外部");

    private Integer code;
    private String name;

    public static Integer getCodeByName(String name) {
        for (NodeTypeEnum nodeTypeEnum : NodeTypeEnum.values()) {
            if (nodeTypeEnum.getName().equals(name)) {
                return nodeTypeEnum.getCode();
            }
        }
        return 0;
    }

    public static String getNameByCode(Integer code) {
        for (NodeTypeEnum nodeTypeEnum : NodeTypeEnum.values()) {
            if (nodeTypeEnum.getCode().equals(code)) {
                return nodeTypeEnum.getName();
            }
        }
        return "";
    }
}
